#!/usr/bin/php -q
<?php

	error_reporting(0);

	/*
	   PHP Phone Dictionaty Tool creates a dictionary file of phone numbers.
	   Dev. by Patrick de Brouwer (patrick@nlsecurity.org)
	   KnickLighter, 2011-11-04
	*/

	$wpn_ver = "1.0.02";

	function showhelp () {

		global $argv;
		global $wpn_ver;

		$help .= "         ______________________________________                                \n";
		$help .= "________|                                      |_______                        \n";
		$help .= "\       | PHP Phonenumber Dictionary Tool      |      /                        \n";
		$help .= " \      |                By Patrick de Brouwer |     /                         \n";
		$help .= " /      |______________________________________|     \                         \n";
		$help .= "/__________)                                (_________\                        \n";
		$help .= "                                                                               \n";
		$help .= "       =[ ".$argv[0]." [Ver: ".$wpn_ver."]                                     \n";
		$help .= "+ -- --=[ Usage: php ".$argv[0]." -h        - Prints this help                 \n";
		$help .= "       =[        php ".$argv[0]." 010       - Creates a dict. starting from 010\n";

		echo $help;

	}

	if (!$argv[1] OR $argv[1] == "-h" OR $argv[1] == "--help") { showhelp(); die("\n"); }

	$wpn_start = $argv[1];
	$wpn_add = 10 - strlen($wpn_start);

	for ($i = 1; strlen($x) < $wpn_add; $i++) {
		$x .= "9";
	}

	$wpn_dict = $wpn_start."-dict.txt";
	$wpn_fh = fopen($wpn_dict, 'w') or die("[!] Can't write to file: ".$wpn_dict.".\n");

	echo "[i] Creating dictionary file ".$wpn_dict.". Please wait...\n";

	for ($i = 0; $i < ($x + 1); $i++) {
		$wpn_cur = $i;
		while (strlen($wpn_cur) < $wpn_add) {
			$wpn_cur = "0".$wpn_cur;
		}
		$wpn_ddata = $wpn_start.$wpn_cur."\n";

		fwrite($wpn_fh, $wpn_ddata);
	}

	fclose($wpn_fh);
	echo "[i] Done.\n";

?>
